/*
 * CCS_struct.hpp
 *
 *  Created on: Mar 30, 2010
 *      Author: root
 */

#ifndef CCS_STRUCT_HPP_
#define CCS_STRUCT_HPP_

#include "CCS_include.hpp"


#define  NAME_LENIGHT   20                    //10 chinese'char.
#define  SHOW_OSD_MAX   20
#define  URL_LENGTH     20
#define  ONE_DRIVE_MAX_COMMPORT   5           //
#define  DEVICE_NAME_MAX_LENGTH  20
#define  DEVICE_SEND_BUF_SIZE   1024
#define  DEVICE_RECV_BUF_SIZE   1024


enum comm_type
{
   COMM_TCP_SERVER,
   COMM_TCP_CLIENT,
   COMM_UDP,
   COMM_USART
};

enum  matrix_out_type
{
   OUT_TYPE_MONITOR,
   OUT_TYPE_PUBLIC_TRUN,
   OUT_TYPE_PRIVATE_TRUN
};

enum  matrix_int_type
{
   INT_TYPE_CAMERA,
   INT_TYPE_PUBLIC_TRUN,
   INT_TYPE_PRIVATE_TRUN
};
enum  cmd_exec_over_code
{
   CMD_EXEC_OK,
   CMD_EXEC_BAD,
   CMD_EXEC_COMMAND_UNKNOW,
   CMD_EXEC_ON_ACCESS,
   CMD_EXEC_COMM_NOT_READLY,
   CMD_EXEC_NOT_FIND_PATH,
   CMD_EXEC_UNKNOW,
   CMD_EXEC_NO_FREE_TURN
};

enum camera_control_switch_cmd
{
   CAMERA_SWITCH,
   PTZ_UP_START,
   PTZ_UP_STOP,
   PTZ_DOWN_START,
   PTZ_DOWN_STOP,
   PTZ_LEFT_START,
   PTZ_LEFT_STOP,
   PTZ_RIGHT_START,
   PTZ_RIGHT_STOP,

   PTZ_LEFT_UP_START,
   PTZ_LEFT_UP_STOP,
   PTZ_RIGHT_UP_START,
   PTZ_RIGHT_UP_STOP,
   PTZ_LEFT_DOWN_START,
   PTZ_LEFT_DOWN_STOP,
   PTZ_RIGHT_DOWN_START,
   PTZ_RIGHT_DOWN_STOP,

   PTZ_ZOOM_IN_START,
   PTZ_ZOOM_IN_STOP,
   PTZ_ZOOM_OUT_START,
   PTZ_ZOOM_OUT_STOP,

   PTZ_FOCUS_FAR_START,
   PTZ_FOCUS_FAR_STOP,
   PTZ_FOCUS_NEAR_START,
   PTZ_FOCUS_NEAR_STOP,

   PTZ_APERTURE_OPEN_START,
   PTZ_APERTURE_OPEN_STOP,
   PTZ_APERTURE_CLOSE_START,
   PTZ_APERTURE_CLOSE_STOP,

   PTZ_LIGHT_OPEN,
   PTZ_LIGHT_CLOSE,

   PTZ_WASH_START,
   PTZ_WASH_STOP
};
//#0,1,[C22=j2]0d
//#0,1,[J33=k0]0d
//af,de,g,d,
//      u32 command_type;   //switch,ptz,osd.....

struct t_driver_sub
{
      u8 node_type;        //const,%s,%d,%lu,%8 ,crc.
      u8 node_link_type;   //camera,monitor,firstslot... or crc.
      u8 node_min_len;     //save 00
      u8 node_diasg;       //0=none,1=+ 2=- ..* /
      u32 node_diasg_data;  // shu .
      struct list_head list;
};

struct t_driver
{
      u8 driver_type;        //ptz or switch or osd
      t_driver_sub * device_sub;
      struct list_head list;
};


struct t_commlist
{
	u32 commmid;
	struct list_head list;
};

struct t_matrix
{
   u32 id;
   u8 name[NAME_LENIGHT];
   u32 max_input;
   u32 max_output;
   struct list_head Comm_list;
   struct list_head list;
};
/*
struct t_trun  //all is trun
{
  u32 id;
  u32 trun_code;
  u32 trun_type;
  u32 input_firstmatrixno;
  u32 input_firstslot;
  u32 input_firstport;
  u32 input_sencondmatrixno;
  u32 input_sencondslot;
  u32 input_sencondport;
  u32 input_matrixid;
  u32 output_matrixno;
  u32 output_slot;
  u32 output_port;
  u32 output_matrixno;
  u32 selectcamera;
  u32 usergroup;
  struct list_head list;
};
*/
struct t_matrix_input
{
	u32 id;
	u8 name[NAME_LENIGHT];
	u32 input_no;
	matrix_int_type inttype;
    u32 firstmatrixno;                  // first matrix number
    u32 firstslot;
    u32 firstport;
    u32 sencondmatrixno;                  // first matrix number
    u32 sencondslot;
    u32 sencondport;
    u32 matrixid;
    bool lock;
    struct list_head list;
};

struct t_matrix_output
{
	u32 id;
	u32 output_no;
	u8 name[NAME_LENIGHT];
	matrix_out_type   outtype;
    u32 matrixno;                        // first matrix number
    u32 slot;
    u32 port;
    u32 matrixid;
    u32 useduser;                       //
    u32 selectcameraid;                  //
    u32 runscanid;
    bool lock;
    struct list_head list;
};

struct t_camera_control
{
   u32 id;
   u32 camera_id;                         //from camera' id
   u32 ctrol_matrix;
   u32 ctrol_slot;
   u32 ctrol_port;
   bool auto_pretest;
   struct list_head Comm_list;
   struct list_head list;
};

struct t_camera_control_exchange
{
   u32 id;
   u32 camera_control_id;
   /*
    *  exchange camera'control
   */
   camera_control_switch_cmd from;
   camera_control_switch_cmd to;
   struct list_head list;
};
enum osd_show_type
{
     OSD_SHOW_TYPE_DATE,
     OSD_SHOW_TYPE_CAMERA_NAME,
     OSD_SHOW_TYPE_MONITOR_NAME,
     OSD_SHOW_TYPE_CAMERA_NO,
     OSD_SHOW_TYPE_MONITOR_NO,
     OSD_SHOW_TYPE_TRUN_NO,
     OSD_SHOW_TYPE_TRUN_NAME,
     OSD_SHOW_TYPE_USER,
     OSD_SHOW_TYPE_ERROR
};


struct t_osd_show_list
{
    u32 id ;
    u32 osdid;
    osd_show_type  showtype;    // //0 datetime,1 camera name,2 opertor name,3 monitor name 4 trun name 5 alarm 6 event.
    u32 show_x;
    u32 show_y;
    u32 show_stop_time;
    u32 const_str[SHOW_OSD_MAX];
    struct list_head list;
};
enum osd_link_device
{
	OSD_LINK_CAMER,
	OSD_LINK_MONITOR
};
struct  t_osd
{
  u32 id;
  u8 name[NAME_LENIGHT];
  osd_link_device linkdevice;
  u32 linkport;
  u32 matrixno;
  u32 slotno;
  u32 port;
  u32 inist;
  u32 defaultx;
  u32 defaulty;                                    //used to inistart.
  struct list_head Comm_list;
  struct list_head list;
};


struct t_commport
{
	u32 id;
	u8 name[NAME_LENIGHT];
	comm_type commtype;
	u8  port_path[URL_LENGTH];    //ip no usart name
    u32 port;
    u8  data;                       //8,data bit
    u8  chk_data;                   //8
    u8  sotp_bit;                   //stop
    struct list_head list;
};


struct t_gateway
{
    u32 id;
    u8  name[NAME_LENIGHT];
    u32 my_node;
    u32 remoter_node;
    u32 commport_id;
    struct list_head list;
};


struct t_scan
{
    u32 id;
    u8  name[NAME_LENIGHT];
    u32 scan_no;
    u32 waittime;
    struct list_head camera_list;
    struct list_head list;
};
struct t_macro_command
{
	u32 id;
	u32 macroid;
	u32 command;
    u32 parameter1;
    u32 parameter2;
    u32 parameter3;
	struct list_head list;
};

struct t_macro
{
	u32 id;
	u8 name[NAME_LENIGHT];
	struct list_head list;
};
struct t_usergroup
{
	u32 id;
	u8  name[NAME_LENIGHT];
	u32 level;                      //begin to 1-->
	struct list_head list;
};

struct t_user
{
	u32 id;
	u32 code;
	u8 name[NAME_LENIGHT];
	u8 password[NAME_LENIGHT];
	u32 groupid;
	struct list_head list;
};
struct t_groupaccess
{
	u32 id;
	u32 groupid;
	u32 itemid;
	u32 access;
	struct list_head list;
};


enum key_press_char               //key
{
  KEY_NUMBER_0,
  KEY_NUMBER_1,
  KEY_NUMBER_2,
  KEY_NUMBER_3,
  KEY_NUMBER_4,
  KEY_NUMBER_5,
  KEY_NUMBER_6,
  KEY_NUMBER_7,
  KEY_NUMBER_8,
  KEY_NUMBER_9,
  KEY_MON,
  KEY_CAM,
  KEY_VIEW,
  KEY_ENTER,
  KEY_UP,
  KEY_DOWN,
  KEY_USER_MACRO,
  KEY_SCAN,
  KEY_SET,
  KEY_HALT,
  KEY_PAUSE,
  KEY_IN,
  KEY_OUT,
  KEY_FAR,
  KEY_NEAR,
  KEY_OPEN,
  KEY_CLOSE,
  KEY_WASH,
  KEY_WIPE,
  KEY_LIGHT
};

#endif /* CCS_STRUCT_HPP_ */
